package com.matrix.media.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.matrix.common.context.RequestContext;
import com.matrix.common.entity.PageResult;
import com.matrix.common.exception.BaseException;
import com.matrix.common.service.BaseService;
import com.matrix.common.service.impl.BaseServiceImpl;
import com.matrix.media.dto.MixedCutProjectDTO;
import com.matrix.media.dto.MixedCutProjectPageQueryDTO;
import com.matrix.media.entity.project.MixedCutProject;
import com.matrix.media.mapper.MixedCutProjectMapper;
import com.matrix.media.service.MixedCutProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MixedCutProjectServiceImpl extends BaseServiceImpl implements MixedCutProjectService {

    @Autowired
    RequestContext requestContext;

    @Autowired
    MixedCutProjectMapper mixedCutProjectMapper;

    @Override
    public PageResult pageQuery(MixedCutProjectPageQueryDTO mixedCutProjectDTO) {
        PageHelper.startPage(mixedCutProjectDTO.getPage(), mixedCutProjectDTO.getPageSize());
        Page<MixedCutProject> mixedCutProjects = mixedCutProjectMapper.pageQuery(mixedCutProjectDTO);
        return new PageResult(mixedCutProjects.getTotal(), mixedCutProjects.getResult());
    }

    @Override
    public void addMixedCutProject(MixedCutProjectDTO projectDTO) {
        MixedCutProject mixedCutProject = new MixedCutProject();
        BeanUtils.copyProperties(projectDTO, mixedCutProject);
    }
}
